#!/usr/bin/env node

const cp = require('child_process'),
      argv = process.argv;

let cmd = '',//命令
    arg = [];//命令的参数

if(argv.length===2){
  cmd = 'cat';
  arg.push('01-exec-file.js');
}else{
  cmd = argv[2];
  arg = argv.slice(3,argv.length);
}

cp.execFile(cmd,arg,(error,out,err) => {
  if(error){
    console.error(err.toString('utf8'));
    process.exit(1);
  }else{
    console.log(out.toString('utf8'));
  }
})
//console.log(process.env);
//process.exit();
